package Action;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.eventdao;
import Entity.Event;
import mapper.Eventmapper;

/**
 * Servlet implementation class eventQueryServlet
 */
@WebServlet("/eventQueryServlet")
public class eventQueryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public eventQueryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String d =request.getParameter("date");
        java.util.Date da=null;
        try {
            da= sdf.parse(d);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        java.sql.Date date = new java.sql.Date(da.getTime());
        int type = Integer.parseInt(request.getParameter("typeT"));
        int order = Integer.parseInt(request.getParameter("order"));
        String room = request.getParameter("room");
        String eid = request.getParameter("test_id");
        Event event=new Event();
        event.setDate(date);
        event.setOrder(order);
        event.setRoom(room);
        event.setType(type);
        Eventmapper em = new eventdao();
        em.CreatEvent(event);
        request.getRequestDispatcher("EventServlet?page=1").forward(request,response);
	}
}
